
import Environments from '@/visual/commons/utils/env-util';
import type { Router } from 'vue-router';

const viteSysTitle = Environments.getEvnProp('VITE_SYS_TITLE');

export function createBrowserTitleGuard(router: Router) {
  router.beforeEach(async (to) => {
    if (to.meta.loaded) return true;
    let sysTitle = viteSysTitle || '管理系统';
    sysTitle += to.meta && to.meta.title ? '-' + to.meta.title : '';
    document.title = sysTitle;
    return true;
  });
}
